Skip to content

feat(bun): Instrument modules in bun run on Bun 1.4.5 and later - #26515

Open
isaacs wants to merge 2 commits into
developfrom
feat/bun-run-tracing
Open

isaacs wants to merge 2 commits into
developfrom
feat/bun-run-tracing

Conversation

@isaacs

@isaacs isaacs commented Nov 17, 2026

Copy link
Copy Markdown
Member

Bun 1.4.5 fixes CommonJS modules that a runtime onLoad plugin returns (oven-sh/bun#19279). Before, they lost their named exports, so the orchestrion transform could only run in bun build.

Sentry.init() from @sentry/bun now registers the orchestrion transform with Bun.plugin(). The new @sentry/bun/import preload does the same before the app loads, so it also reaches the static imports of the entry module:

bun --preload @sentry/bun/import app.ts

On older Bun versions the SDK skips the registration, and the warning about missing channel injection tells users to upgrade Bun or build with @sentry/bun/plugin. enableRuntimeChannelInjection: false turns the registration off, as in @sentry/node.

The injected snippet imports @sentry/server-utils from inside the instrumented package. Under isolated installs that specifier does not resolve from there, so an onResolve hook points it at the copy of @sentry/server-utils that the SDK already loaded.

The new node-suites-bun-run integration project runs the auto-instrumentation suites unbuilt on Bun 1.4.5 or later, and CI runs the Bun integration tests on canary too, until 1.4.5 is released.

Bun 1.4.5 fixes CommonJS modules that a runtime `onLoad` plugin returns
(oven-sh/bun#19279). Before, they lost their named exports, so the
orchestrion transform could only run in `bun build`.

`Sentry.init()` from `@sentry/bun` now registers the orchestrion
transform with `Bun.plugin()`. The new `@sentry/bun/import` preload does
the same before the app loads, so it also reaches the static imports of
the entry module:

    bun --preload @sentry/bun/import app.ts

On older Bun versions the SDK skips the registration, and the warning
about missing channel injection tells users to upgrade Bun or build with
`@sentry/bun/plugin`. `enableRuntimeChannelInjection: false` turns the
registration off, as in `@sentry/node`.

The injected snippet imports `@sentry/server-utils` from inside the
instrumented package. Under isolated installs that specifier does not
resolve from there, so an `onResolve` hook points it at the copy of
`@sentry/server-utils` that the SDK already loaded.

The new `node-suites-bun-run` integration project runs the
auto-instrumentation suites unbuilt on Bun 1.4.5 or later, and CI runs
the Bun integration tests on canary too, until 1.4.5 is released.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: aed1c80 (PR test merge using develop at d44a8ba)

Against: d44a8ba (develop) · base run #66610

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.18 kB - -
@sentry/browser - with treeshaking flags 28.37 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.28 kB - -
@sentry/browser (incl. Tracing) 52.74 kB - -
@sentry/browser (incl. Tracing Core) 40.27 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.75 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.63 kB - -
@sentry/browser (incl. Tracing, Replay) 92.79 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.61 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.16 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.71 kB - -
@sentry/browser (incl. Feedback) 48.12 kB - -
@sentry/browser (incl. sendFeedback) 30.76 kB - -
@sentry/browser (incl. FeedbackAsync) 35.78 kB - -
@sentry/browser (incl. Metrics) 31.5 kB - -
@sentry/browser (incl. Logs) 31.78 kB - -
@sentry/browser (incl. Metrics & Logs) 32.44 kB - -
@sentry/react 32.19 kB - -
@sentry/react (incl. Tracing) 55.39 kB - -
@sentry/vue 38.38 kB - -
@sentry/vue (incl. Tracing) 55.69 kB - -
@sentry/svelte 30.19 kB - -
@sentry/remix (Remix 3 client bundle) 58.4 kB - -
CDN Bundle 32.11 kB - -
CDN Bundle (incl. Tracing) 53.15 kB - -
CDN Bundle (incl. Logs, Metrics) 34.89 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.71 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 75.92 kB - -
CDN Bundle (incl. Tracing, Replay) 91.03 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.65 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.44 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99 kB - -
CDN Bundle - uncompressed 93.8 kB - -
CDN Bundle (incl. Tracing) - uncompressed 157.13 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 102.13 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 164.75 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 232.25 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 277.28 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 284.91 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 289.21 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 296.83 kB - -
@sentry/nextjs (client) 59.02 kB - -
@sentry/sveltekit (client) 54.03 kB - -
@sentry/core/server 45.04 kB - -
@sentry/core/browser 14.4 kB - -
@sentry/node 152.65 kB +0.42% +638 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.9 kB +0.68% +564 B 🔺
@sentry/node - without tracing 89.29 kB +0.7% +616 B 🔺
@sentry/node - without channel injection 141.07 kB +0.1% +132 B 🔺
@sentry/aws-serverless 99.67 kB +0.64% +630 B 🔺
@sentry/cloudflare (withSentry) - minified 206.95 kB - -
@sentry/cloudflare (withSentry) 480.37 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 232.31 kB - -

View base workflow run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ce0dbce. Configure here.

Comment thread packages/bun/src/sdk.ts Resolved
Move the `bun run` hook into `registerDiagnosticsChannelInjection()` in
`@sentry/server-runtime-injection`, next to the Node and Deno hooks. The
Node client already calls it on Bun, and `@sentry/bun/import` now loads
`@sentry/node/import`.

Before, `@sentry/bun` imported `@sentry/server-utils/orchestrion/bun` and
so loaded the build-time bundler plugin on every import, which
`runtime-entries.test.ts` forbids. The hook now uses the code transformer
that `@sentry/server-runtime-injection` already bundles. It records each
transformed module on `runtime` through the diagnostics hook, as on
Node, so it needs no injected `@sentry/server-utils` import and no
`onResolve` hook for isolated installs.

The registration runs inside the existing `try`, so a failure warns and
leaves the app without channel injection, as on Node. The `onLoad`
callback catches its own errors and loads the module as it is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 1 not successful, 62 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E nextjs-16-cacheComponents (cloudflare) Test (optional) Failing after 10m Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 52s Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (bun) Test (optional) Successful in 56s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 55s Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (deno) Test (optional) Successful in 52s Details
✅ CI: Optional E2E Tests / E2E nextjs-14 (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 25s Details
✅ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry-static Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (latest) Test (optional) Successful in 59s Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (latest) Test (optional) Successful in 49s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-cloudflare Test (optional) Successful in 27s Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think Test (optional) Successful in 53s Details
✅ CI: Optional E2E Tests / E2E astro-7-static Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-without-tracing-send-to-sentry Test (optional) Successful in 53s Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) Successful in 45s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-mastra Test (optional) Successful in 47s Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (cloudflare) Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (development) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (content off, latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 37s Details
✅ CI: Optional E2E Tests / E2E react-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-flue Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 34s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 37s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel Test (optional) Successful in 38s Details
✅ CI: Optional E2E Tests / E2E node-pi-durable Test (optional) Successful in 36s Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 28s Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 28s Details
✅ CI: Optional E2E Tests / E2E node-mastra Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (kv-cache) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 34s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2-tunnel Test (optional) Successful in 46s Details
✅ CI: Optional E2E Tests / E2E supabase-nextjs Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-eve Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 53s Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions Test (optional) Successful in 36s Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 1m Details

@github-actions

Copy link
Copy Markdown
Contributor

One or more gzipped bundles increased by more than 500 bytes. If this increase is intentional, add the Accept Bundlesize Increase label to this PR to rerun and accept the check.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant